#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>

int main()
{
	char ID[100][19] = { 0 };
	char last[100] = { 0 };
	int sum[100] = { 0 };
	int num[17] = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 };
	char z[11] = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' };
	int prime[100] = { 0 };
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%s", ID[i]);
	}
	for (int i = 0; i < n; i++)
	{
		last[i] = ID[i][17];
	}
	for (int j = 0; j < n; j++)
	{
		for (int i = 0; i < 17; i++)
		{
			if (ID[j][i] >= '0'&&ID[j][i] <= '9')
			{
				sum[j] += ((ID[j][i] - '0')*num[i]);
			}
			else
			{
				prime[j] = 1;
				break;
			}
		}
	}
	int count = 0;
	for (int i = 0; i < n; i++)
	{
		if (prime[i] || last[i] != z[sum[i] % 11])
		{
			printf("%s\n", ID[i]);
			count++;
		}
	}
	if (count == 0)
		printf("All passed");
	return 0;
}